package ru.spies.entities;

import static javax.persistence.CascadeType.MERGE;
import static javax.persistence.CascadeType.REFRESH;
import static javax.persistence.FetchType.EAGER;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.Table;


/**
 * The persistent class for the agentsandtasks database table.
 * 
 */
@Entity
@Table(name="agentsandtasks")
@NamedQuery(name="Agentsandtask.findAll", query="SELECT a FROM Agentsandtask a")
public class Agentsandtask implements Serializable, ITableClass {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	@Column(unique=true, nullable=false)
	private Integer id;

	//bi-directional many-to-one association to Agent
	@ManyToOne(fetch=EAGER,cascade={REFRESH, MERGE})
	@JoinColumn(name="id_agent")
	private Agent agent;

	//bi-directional many-to-one association to Task
	@ManyToOne(fetch=EAGER, cascade={REFRESH, MERGE})
	@JoinColumn(name="id_task")
	private Task task;

	private Object paramForFindQuery=null;
	
	public Agentsandtask() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Agent getAgent() {
		return this.agent;
	}

	public void setAgent(Agent agent) {
		this.agent = agent;
	}

	public Task getTask() {
		return this.task;
	}

	public void setTask(Task task) {
		this.task = task;
	}

	@Override
	public void setParamForFindQuery(Object param) {
		paramForFindQuery=param;		
	}

	@Override
	public Object getParamForFindQuery() {
		return paramForFindQuery;
	}

	@Override
	public ITableClass createThisObject() {
		return new Agentsandtask();
	}

	@Override
	public String getQueryForFind() {
		return "SELECT x FROM Agentandtask x WHERE x.id = :param";
	}

}